<template>
    <div>
        <List :songData="data" :flag="false" />
        <div class="loading" v-if="show === true">
            <i class="el-icon-loading"></i>
        </div>
    </div>
</template>

<script>
import { mapState, mapActions } from 'vuex';
export default {
    computed: {
        ...mapState(['userid']),
    },
    components: {
        List: () => import('../components/List.vue'),
    },
    created() {
        if (this.userid !== null) {
            this.uid = this.userid.userid
            this.getData()
        }
    },
    data() {
        return {
            data: null,
            show: false,
            uid: ''
        }
    },
    methods: {
        getData() {
            this.show = true
            this.data = null
            this.$api.recentSong({ uid: this.uid, type: 1, cookie: localStorage.getItem('cookie'), timestamp: this.$utils.timestamp() }).then((ret) => {
                this.data = ret.weekData
            })
            this.show = false
        }
    },
}
</script>

<style>
</style>